MapService.Control.PrintMap = OpenLayers.Class(OpenLayers.Control, {
    type: OpenLayers.Control.TYPE_BUTTON,
    
    trigger: function(observacao){
    	var me = this;
		
    	if(!observacao){
    		observacao= "";
    	};
    	
    	var title = document.title;
		
		var divMap = document.createElement("div");
		divMap.appendChild(me.map.layerContainerDiv.cloneNode(true));
		
		var printWindow = window.open('#');
		printWindow.document.write('<html> \n');
		printWindow.document.write('<head> \n');
		printWindow.document.write('	<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"> \n');
		printWindow.document.write('	<title>'+title+'</title> \n');
		printWindow.document.write('	<style> \n');
		printWindow.document.write('		.div-map {width: '+me.map.getSize().w+'px; height: '+me.map.getSize().h+'px; border: none; position: relative; overflow: hidden; user-select: none;  -moz-user-select: none;  -khtml-user-select: none; -webkit-user-select: none; -o-user-select: none;}  \n');
		printWindow.document.write('		.div-view {width: '+me.map.getSize().w+'px; height: '+me.map.getSize().h+'px; border: solid 1px; position: relative; overflow: hidden;}  \n');
		printWindow.document.write('		.titulo{float:left;font-size:25px;font-family:Verdana;margin-top:10px;} \n');
		printWindow.document.write('		.observacao{display:none;} \n');
		printWindow.document.write('		@media print { \n');
		printWindow.document.write('			.no-print{display: none;}  \n');
		printWindow.document.write('			.div-view{overflow: hidden;border: none;}  \n');
		printWindow.document.write('			.div-map{overflow: hidden; border: none;} \n');
		printWindow.document.write('			.observacao{display:block !important;} \n');
		printWindow.document.write('			.div-obs{display:none;} \n');
		printWindow.document.write('		}  \n');
		printWindow.document.write('	</style> \n');
		printWindow.document.write('  <script type="text/javascript"> \n');
		printWindow.document.write('	function printMe(){ \n');
		printWindow.document.write('		var textObs = document.getElementById("textObs"); \n');
		printWindow.document.write('		var text = document.getElementById("observacao"); \n');
		printWindow.document.write('		text.innerHTML = ""; \n');
		printWindow.document.write('		if(textObs.value != ""){	 \n');
		printWindow.document.write('			text.innerHTML = "<br/>Observação:<br/>"+textObs.value.replace(/\\n/gi, "<br/>"); \n');
		printWindow.document.write('		} \n');
		printWindow.document.write('		window.print(); \n');
		printWindow.document.write('	} \n');
		printWindow.document.write('  </script> \n');
		printWindow.document.write('</head> \n');
		printWindow.document.write('<body> \n');
		printWindow.document.write('	<div style="width: 700px;float:left;margin-bottom:5px;"> \n');
		printWindow.document.write('		<input type="button" value="Imprimir" style="float: right;"	onclick="printMe();" class="no-print"> \n');
		printWindow.document.write('		<span class="titulo"><script type="text/javascript">document.write(document.title);</script></span> \n');
		printWindow.document.write('		<br clear="all"> \n');
		printWindow.document.write('		<div style="width: 100%;" class="div-obs"> \n');
		printWindow.document.write('			<span>Observação:</span> \n');
		printWindow.document.write('			<br> \n');
		printWindow.document.write('			<textarea id="textObs" style="width: 100%; height: 100px;">'+observacao+'</textarea> \n');
		printWindow.document.write('		</div> \n');
		printWindow.document.write('		<div style="width: 100%;"> \n');
		printWindow.document.write('			<span id="observacao" class="observacao"></span> \n');
		printWindow.document.write('		</div> \n');
		printWindow.document.write('	</div> \n');
		printWindow.document.write('	<br clear="all"> \n');
		printWindow.document.write('	<div id="div-view" class="div-view"> \n');
		printWindow.document.write('	<div id="div-map" class="div-map" > \n');
		printWindow.document.write( divMap.innerHTML );
		printWindow.document.write('	</div> \n');
		printWindow.document.write('</body> \n');
		printWindow.document.write('</html> \n');
		printWindow.document.close();
    },
    
	CLASS_NAME: "MapService.Control.PrintMap"
});